/**
 * 
 */
package org.ezaero.jmimic.api.checker;

import java.util.Arrays;

public class ObjectEqualsChecker implements InvocationChecker {

    public boolean checkInvocation(String actualMethod, Object[] actualArgs, String expectedMethod, Object[] expectedArgs) {
        return (actualMethod.equals(expectedMethod) && Arrays.deepEquals(actualArgs, expectedArgs));
    }

    public boolean checkResponse(String actualMethod, Object actualValue, String expectedMethod, Object expectedValue) {
        if(!actualMethod.equals(expectedMethod)) {
            return false;
        }
        
        if (expectedValue == actualValue) {
            return true;
        }

        if (expectedValue == null) {
            if (actualValue != null) {
                return false;
            }
        } else if (!expectedValue.equals(actualValue)) {
            return false;
        }

        return true;
    }
}